using System;
using Gtk;
using System.Data;
using MySql.Data.MySqlClient;

namespace People
{
	
	public class NewContact : Gtk.Dialog
	{
		protected Gtk.Entry entry1;
		protected Gtk.Entry entry2;
		
		public NewContact()
		{
			Stetic.Gui.Build(this, typeof(People.NewContact));
		}

		protected virtual void SendData(object sender, System.EventArgs e)
		{
			string connectionString =
          "Server=localhost;" +
          "Database=GNA;" +
          "User ID=root;" +
          "Password=;" +
          "Pooling=false";
       IDbConnection dbcon;
       dbcon = new MySqlConnection(connectionString);
       dbcon.Open();
       IDbCommand dbcmd = dbcon.CreateCommand();
    
       string sql = "INSERT into People(FirstName,LastName) VALUES ('" + entry1.Text + "','"+ entry2.Text + "')";
       dbcmd.CommandText = sql;
       dbcmd.ExecuteNonQuery();
      		
       // clean up

       dbcmd.Dispose();
       dbcmd = null;
       dbcon.Close();
       dbcon = null;
			this.Hide();
			
		}
	}
}
